const env=require('./env.js')
export default {
  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: '硅谷甄选',
    htmlAttrs: {
      lang: 'en'
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
      { rel:'stylesheet', type: 'text/css', href: '/style.css' },
      { rel:'stylesheet', type: 'text/css', href: '/public/haha.css' }

    ]
  },

  // Global CSS: https://go.nuxtjs.dev/config-css

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
    '@/plugins/element-ui'
  ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
  ],

  // Axios module configuration: https://go.nuxtjs.dev/config-axios
  axios: {
    // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
    baseURL: '/',
  },

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    transpile: [/^element-ui/],
    extractCSS: true,
    // filenames:{
    //   app: ({ isDev }) => 'js/[name].[hash].js',
    //   chunk: ({ isDev }) =>  'js/[name].[hash].js',
    //   css: ({ isDev }) =>  'css/[name].[contenthash].css',
    //   img: ({ isDev }) =>  'images/[name].[contenthash:7].[ext]',
    //   font: ({ isDev }) =>  'fonts/[name].[contenthash:7].[ext]',
    //   video: ({ isDev }) => 'videos/[name].[contenthash:7].[ext]'
    // },
    optimization: {
      splitChunks: {
        chunks: 'all',
        automaticNameDelimiter: '.',
        maxAsyncRequests: 7,
        cacheGroups: {

          vuetify: {
            test: /node_modules[\\/]vuetify/,
            chunks: 'all',
            priority: 20,
            name: true
          },
          elementui: {
            test: /node_modules[\\/]element-ui/,
            chunks: 'all',
            priority: 20,
            name: true
          }
        }
      }
    },
    publicPath: '/public',
    babel: {
      plugins: [
        [ "component",
          {
          "libraryName": "element-ui",
          "styleLibraryName": "theme-chalk"
          }
        ]
      ]
    },
    postcss:{
      postcssOptions:{
        plugins:{
          autoprefixer: {},
          // "postcss-px-to-viewport":{
          //   'viewportWidth': '2560', // 视窗的宽度，对应的是我们设计稿的宽度
          //   'viewportHeight': '1440' // 视窗的高度
          // }
          "postcss-px-to-viewport-8-plugin":{
              'viewportWidth': '2560', // 视窗的宽度，对应的是我们设计稿的宽度
              'viewportHeight': '1440', // 视窗的高度
              // 'exclude':[/Head/,/UserInfo/]
          }
        }
      }

    }
  },
  env: {
    NUXT_ENV: env[process.env.MODE]
  },
  server: {
    port: 8000, // default: 3000
    host: '0.0.0.0', // default: localhost,
    timing: false
  },
  vue:{
    config: {
      productionTip: true,
      devtools: false,
      errorHandler : (err, instance, info) => {
        // handle error, e.g. report to a service
        console.log(err,instance,info)
      }
    }
  }
}
